package com.example.aop;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import com.example.aop.config.AppConfig;

public class Main {
    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        OrderService orderService = context.getBean(OrderService.class);
        
        System.out.println("=== 测试add方法 ===");
        try {
            orderService.add("苹果", 5);
        } catch (Exception e) {
            System.out.println("add方法执行失败：" + e.getMessage());
        }
        
        System.out.println("\n=== 测试delete方法 ===");
        try {
            orderService.delete("香蕉");
        } catch (Exception e) {
            System.out.println("delete方法执行失败：" + e.getMessage());
        }
        
        System.out.println("\n=== 测试find方法 ===");
        try {
            orderService.find("橙子");
        } catch (Exception e) {
            System.out.println("find方法执行失败：" + e.getMessage());
        }
    }
}
